<include file="__THEME__/header" />
<script type="text/javascript" src="./public/js/xheditor-1.1.12/xheditor.js"></script>
<script type="text/javascript">
$(document).ready(function(){    
   $("#post-tag-input").die().live("keydown",function(event){    
        if(event.keyCode==13){ 
		   
		   var tag_name = $('#post-tag-input').val().replace(/[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g,""); 
		   if(tag_name=='') return false;
		  // alert(tag_name);
		   var html ='';
		   html+='<li  tag="'+tag_name+'">';
		   html+='<span>'+tag_name+'</span>';
		   html+='<a href="javascript:void(0);" class="delete-tag-btn" title="删除">×</a>';
		   html+='</li>'
           $('#tag_ul_list').append(html); 
		   $('#post-tag-input').val("").focus();
         }    
    }); 
	$('.delete-tag-btn').live('click', function() {
	 $(this).parent().remove();
    });
  
   $('#blog_tag_name_box').click(function(){
	 $('#post-tag-input').focus();
  
   });
}); 

</script>
<div class="content no_bg"><!-- 内容 begin  -->
<form id="form1" name="form1" method="post" action="{:U('home/blog/checkall')}" enctype="multipart/form-data" onsubmit="return post_check()"  onkeydown="if(event.keyCode==13){return false;}">
    <div class="main no_l">
      <div class="mainbox">
        <div class="mainbox_R">
          <div class="right_box">
            <p>
              <input type="hidden" name="weibo_id" value="{$bloglist[weibo_id]}">
              <input type="hidden" name="blog_id" value="{$bloglist[blog_id]}">
              <select name="status" id="blog_status" class="text35">
                <option 
                <eq name="bloglist.status" value="1" >selected</eq>
                 value="1">立即发布
                </option>
                <option 
                <eq name="bloglist.status" value="2" >selected</eq>
                  value="2">仅自己可见
                </option>
              </select>
            </p>
            <br/>
            <h1 class="f16px">
            标签
            </h1>
            <p>
              <div class="post-tag-holder"  id="blog_tag_name_box">
  <div class="post-tag">
    <ul id="tag_ul_list">
    </ul>
    <div class="post-tag-input">
      <input type="text" name="textfield" id="post-tag-input"  value="添加标签,用回车分隔" onfocus="if(this.value == '添加标签,用回车分隔')this.value = ''" onblur="if(this.value=='')this.value='添加标签,用回车分隔'"/>
    </div>
  </div>
</div>
<input type="hidden" name="tag_names"  value="" id="tag_names" />
            </p>
            <p>
            <ul id="tag_list" class="tagList">
              <volist id="vo" name="bloglist['tag']">
                <li><a class="a1" href="{:U('home/user/searchtag',array('k'=>$vo['tag_name']))}">{$vo.tag_name}</a><a class="a2" onclick="deleteTag(this)" tagid="{$vo.user_tag_id}" href="javascript:;"><img class="del" src="__THEME__/images/zw_img.gif" /></a></li>
              </volist>
            </ul>
            </p>
          </div>
        </div>
        <div class="mainbox_CR" > 
          
          <!-- ========== 写文章 begin ============= -->
          <div> <span class="f16px">标题：</span><span class="f12px">(标题可不填)</span>
            <p>
              <input type="text" name="title" id="blog_title"  class="title35"  onfocus="this.className='title35on'" onblur="this.className='title35'" value="{$bloglist['title']}"/>
            </p>
            <br/>
            <span class="f16px">内容：</span>
            <p>
              <textarea id="blog_content" name="content" style="width:750px;height:350px">{$bloglist['content']}</textarea>
            </p>
            <br/>
            <span>
            <input type="submit" name="button"  value=" " id="post_blog_all" class="btn_big" onclick="post_check();"/>
            <a href="javascript:history.go(-1);"class="btn_w">取消</a> </span> </div>
          
          <!--  写文章 end--> 
        </div>
        <div class="clear"></div>
      </div>
    </div>  
	</from>
    <!-- 内容 end -->
  
</div>
<script>
$(document).ready(function(){
var plugins={
	Code:{c:'btnCode',t:'插入代码',h:1,e:function(){
		var _this=this;
		var htmlCode='<div>插入代码</div><div><textarea id="xheCodeValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';			var jCode=$(htmlCode),jType=$('#xheCodeType',jCode),jValue=$('#xheCodeValue',jCode),jSave=$('#xheSave',jCode);
		jSave.click(function(){
			_this.loadBookmark();
			_this.pasteHTML("<p class=\"code\" >" + jValue.val() + "</p><br />");
			_this.hidePanel();
			return false;
		});
		_this.showDialog(jCode);
	}}
}
var description=$('#blog_content').xheditor({plugins:plugins,loadCSS:'<style>body  {font-family:"Arial", "Verdana";font-size:12px;margin: 0;}.code{margin: 5px 0;padding: 10px;text-align: left;display: block;overflow: auto;font-size:20px;background: #FAFAFA;border: 1px solid #f2f2f2;font: 500 1em/1.5em "Lucida Console", "courier new", monospace ;}</style>',tools:'Bold,Italic,Underline,Strikethrough,|,List,Img,Emot,|,Preview,btnCode,Fullscreen,Source',skin:'default',upLinkUrl:'{:U('home/Attach/xheditor')}',upImgUrl:'{:U('home/Attach/xheditor')}',upFlashUrl:'{:U('home/Attach/xheditor')}',upFlashExt:'swf,flv',upMediaUrl:'{:U('home/Attach/xheditor')}',html5Upload:false});
});

function post_check(){
    var blog_title   = $('#blog_title').val();
	var blog_content = $('#blog_content').val();
    var input =$('#post-tag-input').val();
	var tag_names    = $('#tag_ul_list').text()+(input=="添加标签,用回车分隔"?input:'');
	$('#tag_names').val(tag_names.replace(/\s+/g,""));
	//alert(tag_names); return false;
	//onkeydown="if(event.keyCode==13){alert('f');}"
	if(blog_title.length > 30){
	  ui.error('标题不能超过30字');
	  //$this.focus();
	  return false;
	}else if(!blog_content){
	  ui.error('正文内容不能为空');
	  return false;
	}else if(!tag_names){
	  ui.error('标签不能为空');
	  return false;
	}
}
</script> 
<include file="__THEME__/footer" /> 